#include "base/lock.h"

namespace sangame {
namespace base {

Lock::Mutex::Mutex()
{
    InitializeCriticalSection(&critical_section_);
}

Lock::Mutex::~Mutex()
{
    DeleteCriticalSection(&critical_section_);
}

void Lock::Mutex::Lock()
{
    EnterCriticalSection(&critical_section_);
}

void Lock::Mutex::UnLock()
{
    LeaveCriticalSection(&critical_section_);
}


Lock::Lock( Mutex &mutex ) : mutex_(mutex)
{
    mutex_.Lock();
}

Lock::~Lock()
{
    mutex_.UnLock();
}

}
}